package lock_thread;

import java.util.concurrent.locks.LockSupport;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/5/9
 * Time:15:17
 * LockSupport
 **/
public class Demo10 {
    public static void main(String[] args) throws InterruptedException {
        Object lock = new Object();
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("线程1 进入休眠");
                //线程休眠
                LockSupport.park();
                System.out.println("线程1 执行完成");
            }
        },"t1");

        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("线程2 进入休眠");
                //线程休眠
                LockSupport.park();
                System.out.println("线程2 执行完成");
            }
        },"t2");

        Thread t3 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("线程3 进入休眠");
                //线程休眠
                LockSupport.park();
                System.out.println("线程3 执行完成");
            }
        },"t3");

        t1.start();
        t2.start();
        t3.start();

        Thread.sleep(100);
        System.out.println("---------------");
        LockSupport.unpark(t3);

        Thread.sleep(100);
        LockSupport.unpark(t1);

        Thread.sleep(100);
        LockSupport.unpark(t2);

    }
}
